const reqlib = require('app-root-path').require
const webDataUtil = reqlib('/app/util/webDataUtil')

// function parseValue (val) {
//   return parseFloat(val || 0) || 0
// }

// 合约执行卖出
module.exports = async function exSell ({
  usdtKey,
  quantity,
  btbItem,
  btbLeverage
}) {
  if (!quantity) {
    return false
  }
  await webDataUtil.binance('futuresLeverage', {
    key: usdtKey,
    quantity: btbLeverage || 1
  })
  // 卖出
  const sellRes = await webDataUtil.binance('futuresMarketSell', {
    key: usdtKey,
    quantity: quantity
  })
  const resData = sellRes.data || {}
  if (!resData.orderId) {
    return false
  }
  return {}
}
